package cate.common.table.d;

import cate.common.table.common.ParamSheet;
import easy.java.dev.note.NoteClass;
import easy.java.dev.note.NoteField;

import java.util.ArrayList;
import java.util.List;

@NoteClass("英雄")
public class GDHero {

    @NoteField("等级下限")
    public static final int LEVEL_MIN = 1;

    @NoteField("等级上限")
    public static final int LEVEL_MAX = 5000;

    @NoteField("阶数下限")
    public static final int GRADE_MIN = 0;

    @NoteField("阶数上限")
    public static final int GRADE_MAX = 10;


    @NoteField("英雄受生命之树共享等级的限制")
    public static int HERO_WORLD_TREE_LEVEL_LIMIT;

    @NoteField("生命之树共享等级差距")
    public static int HERO_WORLD_TREE_LEVEL_BETWEEN;

    @NoteField("创角默认赠送英雄")
    public static String DEFAULT_CREATE_REWARD_STR;

    @NoteField("默认赠送看板娘ID")
    public static int DEFAULT_BOARD_ID;

    @NoteField("审核服默认看板娘ID")
    public static int SH_DEFAULT_BOARD_ID;

    /**
     * 获取升星时的主角等级限制（后期改成读单独的表）
     *
     * @param star
     * @return
     */
    public static int getStarUpLevel(int star) {

        switch (star) {
//            case 12:
//                return TWELVE_STAR_LEVEL_REQUIRED;
//            case 13:
//                return THIRTEEN_STAR_LEVEL_REQUIRED;
            default:
                return 0;
        }
    }


    @NoteClass("英雄-职业")
    public static class Job {
        @NoteField("无职业")
        public static final byte NULL = 0;

        @NoteField("战士")
        public static final byte J1 = 1;

        @NoteField("法师")
        public static final byte J2 = 2;

        @NoteField("坦克")
        public static final byte J3 = 3;

        @NoteField("辅助")
        public static final byte J4 = 4;

        public static final byte[] ALL = new byte[] {J1, J2, J3, J4};

        public static String description(Byte t) {
            if (t == null){
                return "NULL";
            }
            switch (t) {
                case NULL:
                    return "无职业";
                case J1:
                    return "战士";
                case J2:
                    return "法师";
                case J3:
                    return "坦克";
                case J4:
                    return "辅助";
                default:
                    return "unsupported";
            }
        }

        public static boolean valid(byte t) {
            for (byte job : ALL) {
                if (t == job) {
                    return true;
                }
            }
            return false;
        }
    }

    @NoteClass("英雄-特征")
    public static class Feature {
        @NoteField("无")
        public static final int NULL = 0;

        @NoteField("BOSS")
        public static final int BOSS = 1;

        @NoteField("以后扩展2")
        public static final int EXT2 = 2;

        @NoteField("以后扩展4")
        public static final int EXT4 = 4;
    }

    @NoteClass("英雄-召唤模式")
    public static class CallMode {

        @NoteField("未知召唤")
        public static final byte UNKNOWN = -1;

        @NoteField("普通召唤")
        public static final byte NORMAL = 0;

        @NoteField("友情召唤")
        public static final byte FRIEND = 1;

        @NoteField("高级召唤")
        public static final byte ADVANCED = 2;

        @NoteField("积分召唤")
        public static final byte POINTS = 3;

        @NoteField("巅峰会武召唤")
        public static final byte PEAK = 4;

        public static final byte fromId(int callId) {
            switch (callId) {
                case 1:
                case 2:
                    return NORMAL;
                case 3:
                case 4:
                    return FRIEND;
                case 5:
                case 6:
                    return ADVANCED;
                case 7:
                    return POINTS;
                case 8:
                case 9:
                    return PEAK;
                default:
                    return UNKNOWN;
            }
        }

        public static String getCallName(int callId) {
            byte mode = fromId(callId);
            switch (mode) {
                case NORMAL:
                    return "普通召唤";
                case FRIEND:
                    return "友情召唤";
                case ADVANCED:
                    return "高级召唤";
                case POINTS:
                    return "积分召唤";
                case PEAK:
                    return "会武券召唤";
                default:
                    return "未知召唤";
            }
        }
    }

    @NoteClass("手办-召唤模式")
    public static class ColltCallMode {

        @NoteField("未知召唤")
        public static final byte UNKNOWN = -1;

        @NoteField("普通召唤")
        public static final byte NORMAL = 0;
        //        @NoteField("友情召唤")
        //        public static final byte FRIEND = 1;
        //        @NoteField("高级召唤")
        //        public static final byte ADVANCED = 2;
        @NoteField("积分召唤")
        public static final byte POINTS = 1;
        @NoteField("普通召唤")
        public static final byte NORMAL2 = 2;

        @NoteField("积分召唤")
        public static final byte POINTS2 = 3;

        public static final byte fromId(int callId) {
            switch (callId) {
                case 1:
                case 2:
                    return NORMAL;
                case 3:
                    return POINTS;
                case 4:
                case 5:
                    return NORMAL2;
                case 6:
                    return POINTS2;
                default:
                    return UNKNOWN;
            }
        }

        public static String getCallName(int callId) {
            byte mode = fromId(callId);
            switch (mode) {
                case NORMAL:
                    return "普通召唤";
                case POINTS:
                    return "积分召唤";
                case NORMAL2:
                    return "混沌普通召唤";
                case POINTS2:
                    return "混沌积分召唤";
                default:
                    return "未知召唤";
            }
        }
    }

    @NoteClass("英雄-重生")
    public static class Reborn {
        @NoteField("免费次数")
        public static int FREE_TIMES;

        @NoteField("英雄是否可重生等级")
        public static int LEVEL_LIMIT;
    }

    @NoteClass("英雄-回退")
    public static class Back {
        @NoteField("免费天数")
        public static int FREE_DAY;

        @NoteField("每天免费次数")
        public static int FREE_TIMES;
    }

    @NoteClass("转移")
    public static class Transfer{
        @NoteField("转移等级限制")
        public static int LEVEL_LIMIT;
    }

    @NoteClass("英雄-性别")
    public static class Sex {
        @NoteField("null")
        public static final byte NULL = -1;

        @NoteField("男性")
        public static final byte MALE = 0;

        @NoteField("女性")
        public static final byte FEMALE = 1;
    }

    public static class UpType {
        @NoteField("normal")
        public static final byte NORMAL = 1;

        @NoteField("分段")
        public static final byte STAGE = 2;

        @NoteField("飞升")
        public static final byte  FLY= 3;
    }

    @NoteClass(value = "英雄-魂晶")
    public static class Vial {
        @NoteField("通用魂晶")
        public static final int GENERAL = 206006;

        @NoteField(value = "自然系魂晶")
        public static final int NATURAL = 206062;

        public static int getItemByCamp(byte camp) {
            switch (camp) {
                case GDCamp.Type.C1:
                case GDCamp.Type.C2:
                case GDCamp.Type.C3:
                case GDCamp.Type.C4:
                    return NATURAL;
                case GDCamp.Type.C5:
                case GDCamp.Type.C6:
                    return GENERAL;
                default:
                    return -1;
            }
        }
    }

    /**
     * 获取默认看板娘id
     * @param sh 是否是审核服
     * @return
     */
    public static int getDefaultBoardId(boolean sh) {
        if (sh) {
            return SH_DEFAULT_BOARD_ID;
        } else {
            return DEFAULT_BOARD_ID;
        }
    }

    /** 读取excel中配置的参数 */
    public static void initialize(ParamSheet param) {
        Reborn.FREE_TIMES = GDParamTool.getInt(param,1001, 7);
        Reborn.LEVEL_LIMIT = GDParamTool.getInt(param, 1002,10);
        Back.FREE_DAY = GDParamTool.getInt(param, 1004, 7);
        Back.FREE_TIMES = GDParamTool.getInt(param, 1005, 3);
        HERO_WORLD_TREE_LEVEL_LIMIT = GDParamTool.getInt(param, 1400 ,100);
        HERO_WORLD_TREE_LEVEL_BETWEEN = GDParamTool.getInt(param, 1401, 40);
        DEFAULT_CREATE_REWARD_STR = GDParamTool.getString(param,100,"1:300301:1#3:100022:1");
        DEFAULT_BOARD_ID = GDParamTool.getInt(param, 101, 1);
        SH_DEFAULT_BOARD_ID = GDParamTool.getInt(param, 108, 501200);
        Transfer.LEVEL_LIMIT = GDParamTool.getInt(param, 200, 30);
    }


}
